package org.nanotek.web;

import java.util.Set;
import java.util.stream.Collectors;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.NoneScoped;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;

import org.nanotek.beans.ArtistCredit;
import org.nanotek.service.ArtistService;
import org.nanotek.service.impl.ArtistCreditIdJASONMapper;

@SuppressWarnings("serial")
@ManagedBean
@NoneScoped
public class ArtistCreditBean extends WebBean<ArtistCredit>{

	private Long artistId; 
	
	private Long artistCreditId;
	
	@Inject private ArtistCredit artistCredit;
	
	private Set<ArtistCredit> artistCredits; 
	
	@EJB
	private ArtistService artistService;
	

	public Set<ArtistCredit> getArtistCredits() {
		return artistCredits;
	}

	public void setArtistCredits(Set<ArtistCredit> artistCredits) {
		this.artistCredits = artistCredits;
	}

	public void findArtistCredits()
	{ 
		artistCredits = artistService.findArtistCredits(artistId);
	}
	
	public Long getArtistCreditId() {
		return artistCreditId;
	}

	public void setArtistCreditId(Long artistCreditId) {
		this.artistCreditId = artistCreditId;
	}

	public ArtistCredit getArtistCredit() {
		return artistCredit;
	}

	public void setArtistCredit(ArtistCredit artistCredit) {
		this.artistCredit = artistCredit;
	}
	

	public Long getArtistId() {
		return artistId;
	}

	public void setArtistId(Long artistId) {
		this.artistId = artistId;
	}

	public String getJsonIds()
	{ 
		return (artistCredits !=null)? artistCredits.stream().map(new ArtistCreditIdJASONMapper()).collect(Collectors.toList()).toString() : "";
	}

	@Override
	public ArtistCredit get() {
		return artistCredit;
	}

}
